From e50dc1a42f949c59889f478188f44f3da6eb980d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 5 Jan 2017 15:21:12 +1300 Subject: [PATCH] Add `--profile check` to `cargo rustc` --- src/bin/rustc.rs | 1 + src/cargo/ops/cargo_rustc/fingerprint.rs | 4 -- src/cargo/util/config.rs | 2 +- tests/check.rs | 83 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 98dd2e894..d812e5eb5 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -88,6 +88,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { Some("dev") | None => CompileMode::Build, Some("test") => CompileMode::Test, Some("bench") => CompileMode::Bench, + Some("check") => CompileMode::Check, Some(mode) => { let err = human(format!("unknown profile: `{}`, use dev, test, or bench", mode)); diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 812240908..3d1f27449 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -153,10 +153,6 @@ impl Fingerprint { })?; let mtime = FileTime::from_last_modification_time(&meta); *slot.0.lock().unwrap() = Some(mtime); - // if let Ok(meta) = fs::metadata(path) { - // let mtime = FileTime::from_last_modification_time(&meta); - // *slot.0.lock().unwrap() = Some(mtime); - // } } LocalFingerprint::Precalculated(..) => return Ok(()) } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 63382c10c..501480e24 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -47,7 +47,7 @@ impl Config { rustdoc: LazyCell::new(), extra_verbose: Cell::new(false), frozen: Cell::new(false), - locked: Cell::new(false), + locked: Cell::new(false), } } diff --git a/tests/check.rs b/tests/check.rs index cf039898d..b01d88e95 100644 --- a/tests/check.rs +++ b/tests/check.rs @@ -300,3 +300,86 @@ fn issue_3419() { assert_that(foo.cargo_process("check"), execs().with_status(0)); } + +// test `cargo rustc --profile check` +#[test] +fn rustc_check() { + if !is_nightly() { + return + } + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::baz(); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + assert_that(foo.cargo_process("rustc") + .arg("--profile") + .arg("check") + .arg("--") + .arg("--emit=metadata"), + execs().with_status(0)); +} + +#[test] +fn rustc_check_err() { + if !is_nightly() { + return + } + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::qux(); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + assert_that(foo.cargo_process("rustc") + .arg("--profile") + .arg("check") + .arg("--") + .arg("--emit=metadata"), + execs().with_status(101)); +} -- 2.30.2